package Utils;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import Entity.*;

public class HibernateUtil {
	
	private static final SessionFactory sessionFactory;
	static 
	{
		 try
	        {
	        	 AnnotationConfiguration config = new AnnotationConfiguration();
	             config.addAnnotatedClass(EmpleadoEntity.class);
	             config.addAnnotatedClass(RolEntity.class);
	             config.addAnnotatedClass(MesaEntity.class);
	             config.addAnnotatedClass(PedidoEntity.class);
	             config.addAnnotatedClass(MesaOcupacionEntity.class);
	             config.addAnnotatedClass(MesaSimpleEntity.class);
	             config.addAnnotatedClass(MesaCompuestaEntity.class);
	             config.addAnnotatedClass(SucursalEntity.class);
	             config.addAnnotatedClass(CajaEntity.class);
	             config.addAnnotatedClass(AreaEntity.class);
	             config.addAnnotatedClass(CartaEntity.class);
	             config.addAnnotatedClass(CafeteriaEntity.class);
	             config.addAnnotatedClass(CocinaEntity.class);
	             config.addAnnotatedClass(BarraEntity.class);
	             config.addAnnotatedClass(FacturasEntity.class);
	             config.addAnnotatedClass(ItemsFacturasEntity.class);
	             config.addAnnotatedClass(ProductoEntity.class);
	             config.addAnnotatedClass(ComandaEntity.class);
	             config.addAnnotatedClass(ItemPedidoEntity.class);
	             config.addAnnotatedClass(TareaEntity.class);
	             config.addAnnotatedClass(ReservaEntity.class);
	             config.addAnnotatedClass(ProveedorEntity.class);
	             config.addAnnotatedClass(InsumoEntity.class);
	             config.addAnnotatedClass(InsumoProductoEntity.class);
	             config.addAnnotatedClass(FormaPagoEntity.class);
	             config.addAnnotatedClass(DepositoAreaEntity.class);
	             config.addAnnotatedClass(DepositoEntity.class);
	             config.addAnnotatedClass(DepositoGeneralEntity.class);
	             config.addAnnotatedClass(DepositoRestoEntity.class);
	             config.addAnnotatedClass(PedidoReposicionEntity.class);
	             config.addAnnotatedClass(StockInsumoEntity.class);
	             sessionFactory = config.buildSessionFactory();
	        }
	        catch (Throwable ex)
	        {
	            System.err.println("Initial SessionFactory creation failed." + ex);
	            throw new ExceptionInInitializerError(ex);
	        }
	}
    
	public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}

